home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Format (UK) 104
/
PC Format 2000 January - Disc 2.iso
/
SETUP.BAK
< prev
next >
Wrap
Text File
|
1996-09-27
|
12KB
|
422 lines
/*---------------------------------------------------------------------------*\
* *
* Interactive Space Encyclopedia Install Program *
* *
* *
* (c) Craig Williams 1996 *
* *
\*---------------------------------------------------------------------------*/
// Constant declarations.
#define PROGRAM_FOLDER_NAME "Andromeda"
#define APPBASE_PATH "Spacewin\\"
#define EXTRA_BLOCKSPACE 200000
#define COMPANY_NAME "Andromeda"
#define PRODUCT_NAME "Interactive Space Encyclopedia"
#define PRODUCT_VERSION "2.00"
#define PRODUCT_KEY "SPACE2.00"
#define DEINSTALL_KEY "SPACEDeInstall"
declare
#include "sddialog.h" // Include script dialog definitions.
// Global variable declarations.
STRING svFolder, svDir, szMsg, szFileSet, szTitle, svResult;
STRING svTarget, szProgram, szTemp, svName, svCompany, szComponentList;
STRING svUninstLogFile, szAppPath, szRegKey, szAppSharedDir, szWin32sVer;
NUMBER nResult, nType, nReturn, nvResult;
LIST listInfo, listButtons, listDescrip;
NUMBER nIcon, nFlag;
// Function declarations.
prototype CheckRequirements();
prototype DetermineComponentInfo( STRING );
prototype EnoughSpace( STRING, STRING, NUMBER );
prototype PerformFileTransfer( STRING );
prototype SetupError( STRING );
prototype SetupScreen();
program
StartHere:
Disable( BACKGROUND );
// Set installation info., which is required for registry entries.
InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
// Set up the installation screen.
SetupScreen();
Enable( DIALOGCACHE );
// Create a Welcome dialog.
WelcomeDlg:
Disable( BACKBUTTON );
Enable( NEXTBUTTON );
SdProductName( PRODUCT_NAME );
SdWelcome( "Welcome to the "+PRODUCT_NAME+" Install", "" );
Enable( BACKBUTTON );
// Test target system for proper configuration.
CheckRequirements();
GetType:
Disable( NEXTBUTTON );
listButtons = ListCreate( STRINGLIST );
listDescrip = ListCreate( STRINGLIST );
ListAddString( listButtons, "@12001;1;255, 0, 255", AFTER );
ListAddString( listButtons, "@12003;1;255, 0, 255", AFTER );
ListAddString( listDescrip, "Typical\n"+
"Recommended for most computers. This is a full\n"+
"installation of the Interactive Space Encyclopedia.", AFTER );
ListAddString( listDescrip, "Compact\n"+
"Recommended for low specification computers. \n"+
"This does not include full screen animations or the\n"+
"Wordprocessor facility.", AFTER );
nType = SdOptionsButtons( "Setup Option", "Select a setup type",
listButtons, listDescrip );
if ( nType = BACK ) then goto WelcomeDlg; endif;
Enable( NEXTBUTTON );
ListDestroy( listButtons );
ListDestroy( listDescrip );
svTarget = TARGETDISK ^ APPBASE_PATH;
szAppSharedDir = svTarget ^ "System";
szComponentList = "FileComponents";
GetTargetLocAndSelection:
szMsg = "Setup will install the %P in the following directory.\n\n"
+"To install to this directory, choose Next.\n"
+"To install to a different directory, choose Browse\n\n";
nReturn = SdAskDestPath("Install To", szMsg, svTarget, 0 );
if ( nReturn = BACK ) then goto GetType; endif;
szAppSharedDir = svTarget ^ "System";
// Perform space check of target drive.
if (EnoughSpace( svTarget, szComponentList, EXTRA_BLOCKSPACE ) = FALSE)
goto GetTargetLocAndSelection;
GetProgramFolderInfo:
svFolder = PROGRAM_FOLDER_NAME;
nResult = SdSelectFolder( "", "", svFolder );
if ( nResult = BACK ) then goto GetType; endif;
Disable( DIALOGCACHE );
szFileSet = "General";
// Prepare InstallSHIELD to record deinstallation information.
DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
RegDBSetItem( REGDB_UNINSTALL_NAME, PRODUCT_NAME );
Enable( STATUS );
Enable( INDVFILESTATUS );
// Enable( SELFREGISTERBATCH );
TARGETDIR = svTarget;
SetStatusWindow(0, "Copying Files...." );
StatusUpdate(ON, 90);
CompressGet("DATA.Z", "*.*", COMP_NORMAL);
// Hide Information Gauges
Disable( FEEDBACK_FULL );
// Create program folder and icons.
CreateProgramIcons:
SetStatusWindow(95, "Creating Program Group and Icons...." );
AppCommand( PROGMAN, CMD_RESTORE );
CreateProgramFolder( svFolder );
StrToLower( svTarget, svTarget );
if (nType = 101) then
AddFolderIcon( svFolder, "Space",
SRCDISK ^ "\\SPACEWIN\\EXE\\SPACEWIN.EXE " + svTarget,
svTarget, "", 0, "", REPLACE );
else
AddFolderIcon( svFolder, "Space Low",
SRCDISK ^ "\\SPACEWIN\\EXE\\SPACEWN1.EXE " + svTarget,
svTarget, "", 0, "", REPLACE );
endif;
AddFolderIcon( svFolder, "Install Video for Windows", SRCDISK ^
"VFW\\SETUP.EXE", "", "", 0, "", REPLACE );
AddFolderIcon( svFolder, "Space ReadMe", "write.exe " + SRCDISK ^ "readme.wri",
svTarget, "", 0, "", REPLACE );
Delay( 1 );
szProgram = WINDIR ^ "UNINST16.EXE";
szProgram = szProgram + " -f" + svUninstLogFile;
AddFolderIcon( svFolder, "Uninstall Space", szProgram,
WINDIR, "", 0, "", NULL );
Delay( 1 );
// Announce setup complete and offer to read README file.
CloseOfInstall:
SetStatusWindow( 100, "Installation complete." );
if (AskYesNo( "Do you want to view the ReadMe file now?", YES) = YES) then
LaunchApp( "WRITE.EXE", SRCDISK ^ "readme.wri" );
endif;
Delay( 1 );
Disable( STATUSDLG );
if (nType = 101) then
szMsg = "Installation is complete. You may run the\n"+
"Interactive Space Encyclopedia by \n"+
"double-clicking the Space Icon.";
else
szMsg = "Installation is complete. You may run the\n"+
"Interactive Space Encyclopedia by \n"+
"double-clicking the Space Low Icon.";
endif;
MessageBox( szMsg, INFORMATION );
ShowProgramFolder( svFolder, SW_SHOW );
exit;
/*---------------------------------------------------------------------------*\
*
* Function: SetupScreen
*
* Purpose: This function will set up the screen look. This includes
* colors, fonts, text to be displayed, etc.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function SetupScreen()
string szBitmap;
number nvDx, nvDy, nStatus, nDxBillboard, nDyBillboard;
begin
GetExtents( nvDx, nvDy );
Enable( FULLWINDOWMODE );
Enable( INDVFILESTATUS );
Enable( BITMAP256COLORS );
Enable( DIALOGCACHE );
SetColor( BACKGROUND, BK_BLUE ); // Gradient blue background.
SetColor( STATUSBAR, BLUE );
// SetTitle( "Interactive Space Encyclopedia", 24, WHITE);
// Caption bar text.
SetTitle( "Interactive Space Encyclopedia Install", 0, BACKGROUNDCAPTION );
Enable( BACKGROUND );
Delay( 1 );
// Show the bitmap - TITLE.BMP is in the _SETUP.LIB file
Enable( BITMAPFADE );
PlaceBitmap( SUPPORTDIR ^ "TITLE.BMP", 1, 10, 10, UPPER_LEFT );
Disable( BITMAPFADE );
end;
/*---------------------------------------------------------------------------*\
*
* Function: CheckRequirements
*
* Purpose: This function will check all minimum requirements for the
* application being installed. If any fail, then the user
* is informed and the installation is terminated.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function CheckRequirements()
number nvDx, nvDy;
number nvVersion;
string svVersion;
begin
// Check screen resolution.
GetExtents( nvDx, nvDy );
if (nvDy < 480) then
MessageBox( "This program requires VGA or better resolution.", WARNING );
exit;
endif;
end;
/*---------------------------------------------------------------------------*\
*
* Function: PerformFileTransfer
*
* Purpose: This function will perform the file transfer and handle
* any error that may occur during the file transfer.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function PerformFileTransfer( szFileSet )
begin
// Set up progress indicator and information gauge.
Disable( DIALOGCACHE );
StatusUpdate( ON, 90 );
SetStatusWindow( 0, "Copying program files..." );
TARGETDIR = WINSYSDIR ;
CompressGet( "data.z", "shared\\*.*", COMP_NORMAL );
// Always include README files, located at the root of the
// DATA.Z library file.
TARGETDIR = svTarget;
CompressGet( "data.z", "*.*", COMP_NORMAL );
// If program files are selected, then add them to file set.
SetStatusWindow( -1, "Copying program files..." );
TARGETDIR = svTarget;
CompressGet( "data.z", "voice\\*.*", COMP_NORMAL );
end;
/*---------------------------------------------------------------------------*\
*
* Function: DetermineComponentInfo
*
* Purpose: This function will place all the separatly identifable
* file components into a component list. It will also
* set the size the files represent and will by default
* enable each to be selected.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function DetermineComponentInfo( szFileList )
number nvSize;
string svSize;
begin
/* CompressInfo( "data.z", "voice\\*.*",
COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR,
nvSize, svSize );
ComponentAddItem( szFileList, ITEM_INTROWAV, nvSize, TRUE );
CompressInfo( "data.z", "shared\\*.*",
COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR,
nvSize, svSize );
ComponentAddItem( szFileList, ITEM_THUMBNAILS, nvSize, TRUE );
*/
end;
/*---------------------------------------------------------------------------*\
*
* Function: EnoughSpace
*
* Purpose: This function will determine if enough space exists on
* the target drive based on the selection in thge component
* list.
*
*
* Input:
*
* Returns:
*
* Comments:
\*---------------------------------------------------------------------------*/
function EnoughSpace( svTarget, szComponentList, nExtraSpace )
LIST list;
number nTotal, nvSize, nFreeSpace, nResult;
string svComponent;
begin
// Get total size of all selected components.
list = ListCreate( STRINGLIST );
nTotal = nExtraSpace;
ComponentListItems( szComponentList, list );
nResult = ListGetFirstString( list, svComponent );
while (nResult = 0)
ComponentGetItemSize( szComponentList, svComponent, nvSize );
if (ComponentIsItemSelected( szComponentList, svComponent )) then
nTotal = nTotal + nvSize;
endif;
nResult = ListGetNextString( list, svComponent );
endwhile;
ListDestroy( list );
// Determine if target disk has enough space.
nFreeSpace = GetDiskSpace( svTarget );
if (nFreeSpace < nTotal) then
szMsg = "There is not enough space available, %ld bytes, on the disk\n" +
"'" + svTarget + "' \n" +
"Please free up some space or change the target location\n" +
"to a different disk";
SprintfBox( WARNING, "Setup", szMsg, nTotal );
return FALSE;
endif;
return TRUE; // Enough space.
end;
/*-----------------------------------------------------------------------
Name : SetupError
Purpose : This function will construct messages and info for showing
an error message box.
-------------------------------------------------------------------------*/
function SetupError( szMsg )
begin
MessageBox( szMsg, SEVERE );
exit;
end;
#include "sddialog.rul"